cody - HTMLify profile

cody
4270 Files
636151 Views
Latest files of /cody/swapnilsparsh/30DaysOfJavaScript/130 - Get Mouse Position
*{
padding: 0;
margin: 0;
box-sizing: border-box;
}
body{
height: 100vh;
padding: 0;
margin: 0;
box-sizing: border-box;
}
body{
height: 100vh;
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Position of mouse</title>
<link rel="stylesheet" href="./style.css">
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Position of mouse</title>
<link rel="stylesheet" href="./style.css">
let output = document.getElementById("output");
window.addEventListener("mousemove",(e)=>{
let xPos=e.clientX;
let yPos=e.clientY;
output.innerHTML=`<div><span>X:</span>${xPos}px</div><div><span>Y:</span>${yPos}px</div>`;
})
window.addEventListener("mousemove",(e)=>{
let xPos=e.clientX;
let yPos=e.clientY;
output.innerHTML=`<div><span>X:</span>${xPos}px</div><div><span>Y:</span>${yPos}px</div>`;
})